import React, {Component} from 'react';
import {Form, Icon, Input, Modal} from 'antd';

const FormItem = Form.Item;

class ItemForm extends Component{

    constructor(props){
        super(props);
    }
    componentDidMount(){

    }

    render(){
        const { visible, onCancel, onCreate, form, okText, title } = this.props;
        const { getFieldDecorator } = form;
        const FormItemLayout = {
            labelCol: { span: 5 },
            wrapperCol: { span: 16 },
        };
        return (
            <Modal
                visible={visible}
                title={title}
                okText={okText}
                onCancel={onCancel}
                onOk={onCreate}
            >
                <Form layout="horizontal">
                    {getFieldDecorator('id')(
                        <Input type='hidden'/>
                    )}
                    <FormItem label="类目名称" {...FormItemLayout} hasFeedback>
                        {getFieldDecorator('itemName', {
                            rules: [{ required: true, message: '请输入链接地址！' }],
                        })(
                            <Input />
                        )}
                    </FormItem>
                    <FormItem label="图片地址" {...FormItemLayout} hasFeedback>
                        {getFieldDecorator('itemPic', {
                            rules: [{ required: true, message: '请上传图片！' }],
                        })(
                            <Input />
                        )}
                    </FormItem>
                    <FormItem label="链接地址" {...FormItemLayout} hasFeedback>
                        {getFieldDecorator('linkUrl', {
                            rules: [{ required: true, message: '请输入链接地址！' }],
                        })(
                            <Input />
                        )}
                    </FormItem>
                </Form>
            </Modal>
        );
    }
}

const ItemCreateForm = Form.create()(ItemForm);
export default ItemCreateForm;